package maurice.controller;

import java.awt.Component;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import maurice.controller.event.*;

public class KeyBoardController extends Controller implements KeyListener{
	private Component comp;
	private int up;
	private int aside;
	private int down;
	
	
	public KeyBoardController(Component comp, int up, int aside, int down){
		this.comp = comp;
		this.up = up;
		this.aside = aside;
		this.down = down;
		comp.addKeyListener(this);
	}
	
	@Override
	public void close() {
		// TODO Auto-generated method stub
		comp.removeKeyListener(this);
		
	}

	@Override
	public void keyPressed(KeyEvent arg0) {
		// TODO Auto-generated method stub
		if (arg0.getKeyCode() == up){
			direction = Direction.UP;
			fireMovementConfirmed();
		}
		
		if (arg0.getKeyCode() == aside){
			direction = Direction.ASIDE;
			fireMovementConfirmed();
		}
		
		if (arg0.getKeyCode() == down){
			direction = Direction.DOWN;
			fireMovementConfirmed();
		}
	}

	@Override
	public void keyReleased(KeyEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyTyped(KeyEvent arg0) {
		// TODO Auto-generated method stub
		
	}


}
